package leetcode.array;

import org.junit.Test;

import java.util.Arrays;

/**
 * @author mazouri
 * @create 2021-05-03 10:52
 *
 * https://leetcode-cn.com/problems/remove-element/
 */
public class RemoveElement {
    public int removeElement(int[] nums, int val) {
       int index = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != val){
                nums[index] = nums[i];
                index++;
            }
        }
        return index;
    }

    @Test
    public void test() {
        System.out.println(removeElement(new int[]{0,1,2,2,3,0,4,2},2));
    }
}
